package game.breeze;

import game.breeze.message.AppMessage;
import game.breeze.screen.GameScreen;
import game.breeze.socket.SocketClient;

import com.badlogic.gdx.Game;

public class Breeze extends Game {
	public SocketClient socket;

	@Override
	public void create() {
		try {
			socket = new SocketClient(this, "localhost", 5858);
			socket.start();
			AppMessage msg = AppMessage.createMessage(AppMessage.MSG_CHAT);
			msg.getBuffer().writeUTF("中國1");
			socket.sendMessage(msg);

			msg = AppMessage.createMessage(AppMessage.MSG_CAMPAIGN);
			msg.getBuffer().writeUTF("中國2");
			socket.sendMessage(msg);
			setScreen(new GameScreen(this));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void dispose() {
		super.dispose();
		if (socket != null) {
			socket.stop();
			socket = null;
		}
		System.exit(0);
	}
}
